package com.qing.collector;

import com.qing.dish.Dish;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Demo {

	private static List<Dish> menu= Arrays.asList(
			new Dish("黄焖鸡米饭",false,15,"肉"),
			new Dish("水煮鱼",true,12,"鱼"),
			new Dish("酸菜鱼",false,20,"鱼"),
			new Dish("脆皮鸡米饭",false,18,"米饭"),
			new Dish("麻辣香锅",true,32,"米饭"),
			new Dish("鸡公煲",false,20,"肉"),
			new Dish("汉堡王",true,100,"米饭"),
			new Dish("至尊牛排",false,20,"肉"),
			new Dish("蛋炒饭",true,12,"素"),
			new Dish("咖喱",false,29,"米饭"),
			new Dish("炒白菜",false,8,"素"),
			new Dish("炒萝卜",false,9,"素"),
			new Dish("烤肉",true,50,"肉")
	);

	public static void main(String[] args) {
		//ToListCollector 必须用new来实例化
		menu.stream().collect(new ToListCollector<Dish>());
		//toList是一个工厂
		menu.stream().collect(Collectors.toList());

		menu.stream().collect(ArrayList::new, //供应源
				List::add,  //累加器
				List::addAll); //组合器

		ToListCollector collector=new ToListCollector<Dish>();





	}

}
